/*
 * Description: mount host shared folder
 */
#ifndef SHAREFOLDERHELPER_H
#define SHAREFOLDERHELPER_H
#include <atomic>
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <set>
#include <windows.h>

#include "singleton.h"
#include "rpc_service/sendto_host.h"

using MountItem = std::pair<std::string, std::string>;

namespace GUEST {
class ShareFolderHelper {

public:
    void Init(std::shared_ptr<WINCONTROL::SendToHost> sendtoHost);

    void AddSharedFolder(const std::string &shareName);

    void RemoveSharedFolder(const std::string &shareName);

    void RemoveAllSharedFolder();

    int Deinit();

private:
    void UpdateMountPointRegistry(const std::string &shareName);

    void UpdateMountPointRegistry();

    std::vector<MountItem> GetAllMountedList();

    void OnWindowsSessionChange(int32_t state);

    std::map<const std::string, std::string> sharedPathMap;

    std::atomic<bool> isInit{false};

    std::shared_ptr<WINCONTROL::SendToHost> sendtoHost = nullptr;

    std::mutex mountMutex = {};

    std::string sessionCallbackName_ = "ShareFolderHelper";
};

#define SHARE_FOLDER_HELPER SingletonNew<GUEST::ShareFolderHelper>::GetInstance()
}  // namespace GUEST
#endif